﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DotNet.Utilities
{
    public class IntUtil
    {
        /// <summary>
        /// min&lt;i && i&lt;max
        /// </summary>
        /// <param name="min">最小数</param>
        /// <param name="max">最大数</param>
        /// <param name="i">要判断的数字</param>
        /// <returns></returns>
        public static bool Between(int min, int max, int i)
        {
            return min < i && i < max;
        }
        /// <summary>
        /// int数组是否包含指定数字
        /// </summary>
        /// <param name="list"></param>
        /// <param name="i"></param>
        /// <returns></returns>
        public static bool Contains(int[] list, int i)
        {
            bool b = false;
            foreach (int t in list)
            {
                if (t == i)
                {
                    b = true;
                    break;
                }
            }
            return b;
        }
        /// <summary>
        /// 字符串中是否包含i(Contains("12,22,35", ',', 2) is false)
        /// </summary>
        /// <param name="str">int数组的字符串表示形式</param>
        /// <param name="c">连接数字的字符</param>
        /// <param name="i">是否包含该数字</param>
        /// <returns></returns>
        public static bool Contains(string str, char c, int i)
        {
            string[] ss = str.Split(c);
            string s = i.ToString();
            bool b = false;
            foreach (string t in ss)
            {
                if (t == s)
                {
                    b = true;
                    break;
                }
            }
            return b;
        }
    }
}
